/*
 * Created on 2008-06-08
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package elka.isi.operator.writer;

import java.io.FileOutputStream;
import java.io.PrintWriter;

import org.apache.commons.lang.SystemUtils;
import org.evolvica.core.IIndividualSet;
import org.evolvica.core.common.ASCIIFileWriter;
import org.evolvica.util.Directory;
import org.evolvica.util.EVLog;

/**
 * @author Zibi
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public abstract class EcosystemStateWriter extends ASCIIFileWriter {


	protected static final String DELIMITER = "\t";

	
	/**
	 * W klasach pochodnych po prostu wywolac ten konstruktor.
	 * @param filename nazwa pliku do ktorego beda zapisywane dane.
	 */
	public EcosystemStateWriter(String filename) {
		directory = new Directory("output");
		String file = directory + SystemUtils.FILE_SEPARATOR + filename;
	
		try {
			writer = new PrintWriter(new FileOutputStream(file));
		} catch (Exception fnfe) {
			EVLog.error(
				"saving individual collection to file "
					+ file
					+ " failed : unable to open file",
				fnfe);
		}
	}
	
	protected PrintWriter writer ;
	

	/**
	 * Aby stworzyc writer wypisujacy dane wartosci,
	 * nalezy odziedziczyc po tej klasie i zaimplementowac
	 * te metode.
	 */
	public abstract void write(IIndividualSet set);
	
	/**
	 * Na koniec wykonania algorytmu trzeba zamknac plik.
	 */
	public void close(){
		writer.close();
	}


}
